//
//  ColllectionViewController.m
//  Leisure
//
//  Created by xalo on 16/7/5.
//  Copyright © 2016年 朱旭东. All rights reserved.
//

#import "ColllectionViewController.h"

@interface ColllectionViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation ColllectionViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem  alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRewind target:self action:@selector(backAction)];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"ReadListCell" bundle:nil] forCellReuseIdentifier:@"ReadListModel_cell"];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [[CoreDataManager defaultManager]selectAllCollectionModel].count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    ReadListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ReadListModel_cell" forIndexPath:indexPath];
    [cell setCellWithCollectionModel:[[CoreDataManager defaultManager]selectAllCollectionModel][indexPath.row]];
    
    
    return cell;
}

- (void)backAction{

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 200;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    CollectionDetalsViewController *VC = [[CollectionDetalsViewController alloc] initWithNibName:@"CollectionDetalsViewController" bundle:nil];
    VC.html = [[[CoreDataManager defaultManager] selectAllCollectionModel][indexPath.row]html];
    
    [self.navigationController pushViewController:VC animated:YES];
}
@end
